<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="../common/init_context.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>处理中，请稍后....</title>
<style type="text/css">
.Absolute-Center {
  width: 150px;
  height: 100px;
  text-align:center;
  overflow: auto;
  margin: auto;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
}
</style>
<script type="text/javascript" src="${ROOT}/static/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	var ctx = '${ctx}';
	var redirectUrl = '${redirectUrl}';
	var result = '${result}';
	var orderId = '${orderId}';
	var loop =0;
	var time;
	
	function notify(){
		window.location.href=redirectUrl;
	}
	
	function loopNotify(){
		$.ajax({
			url:ctx+"/pay/getOrderResult.shtml?"+(new Date()).getTime(),
			async:false,
			type:"GET",
			dataType:"JSON",
			data:{orderId:orderId}
		}).done(function(data){
			result = data.result;
		});
	}
	
	function timedCount(){
		loop=loop+1;		
		time = setTimeout("timedCount()", 3000);
		if (result == '1' || loop > 3) {
			clearTimeout(time);
			notify();
		} else {
			loopNotify();
		}
	}

	$(function() {
		if (result == '1') {
			notify();
		} else {
			timedCount();
		}
	});
</script>
</head>
<body>
	<div class="Absolute-Center">
		<img alt="" src="${ctx}/static/img/loading.gif"/>
		<p>处理中，请稍后....</p>
	</div>
</body>
</html>
